﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using SalePartial.Model;
using XunPan.Web;
using SalePartial.BLL;
using System.Collections.Generic;
using SalePartial.Utility;

public partial class controls_front_LoginInfo : System.Web.UI.UserControl
{
    ProcessFlowController pfCont = new ProcessFlowController();

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            List<string> roleNameList;
            DateTime lastActTime = DateTime.Now;
            int noReadMsg = 0;
            if (Session["UserName"] == null)
            {
                return;
            }
            if (!SecurityUtility.GetRoleNmLastActTime(Session["UserName"].ToString(), out roleNameList, out lastActTime,out noReadMsg))
            {
                return;
            }
            this.userId.Text = Session["UserName"].ToString();
            for (int i = 0; i < roleNameList.Count; i++)
            {
                if (roleNameList.Count >= 2 && roleNameList[i] == "个人用户")
                {
                    continue;
                }
                if (this.type.Text == string.Empty)
                {
                    this.type.Text = roleNameList[i];
                }
                else
                {
                    this.type.Text =this.type.Text+"&"+ roleNameList[i];
                }

                if (roleNameList[i] == "供应商")
                {
                    lkbtnSupplyLogin.Visible = false;
                }
                else if (roleNameList[i] == "采购商")
                {
                    lkbtnPurchLogin.Visible = false;
                }
            }
            
            this.lastLoginTime.Text = String.Format("{0:yyyy/MM/dd HH:mm:ss}", lastActTime);
            this.NoReadMsg.Text = noReadMsg.ToString("#,0");
        }
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        Session.Clear();
        Session.Abandon();
        FormsAuthentication.SignOut();
        Response.Redirect(GlobalSetting.UrlHomePage, true);
    }
}
